package com.parttime.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.parttime.beans.Merchant_Users;
import com.parttime.beans.Personal_Users;
import com.parttime.dao.PersonalUsersDao;
import com.parttime.service.PersonalUsersManager;
@Service
public class PersonalUsersManagerImpl implements PersonalUsersManager {

	@Autowired
	private PersonalUsersDao personalUserDao;
	@Override
	//用户注册
	public boolean register(Personal_Users user) {
		// TODO Auto-generated method stub
		return personalUserDao.register(user);
		
	}
	//判断用户表中是否存在某一用户
	@Override
	public boolean exitsUser(Personal_Users user) {
		// TODO Auto-generated method stub
		
		return personalUserDao.exitsUser(user);
	}
	@Override
	public String validateEmail(String phone, String email) {
		// TODO Auto-generated method stub
		if(personalUserDao.exitsUserByAccount(phone)){
			String Email=personalUserDao.getEmailByPhone(phone);
			if(email.equals(Email))return null;
			else return "邮箱填写出错";
		}
		
		return "账号不存在";
	}
	@Override
	public boolean resetPassword(String phone, String password) {
		// TODO Auto-generated method stub
		Personal_Users user=personalUserDao.getUserByPhone(phone);
		user.setU_password(password);
		try{
			if(personalUserDao.saveUser(user)){
			return true;
		}}catch(Exception e){
			return false;
		}
		return false;
	}

}
